(function(angular) {
	'use strict';
	angular.module("fs.waf").factory("dashboardDemoService", dashboardDemoService);
	dashboardDemoService.$inject = [ '$q', 'loggerFactory', 'ajaxServiceFactory' ];
	function dashboardDemoService($q, loggerFactory, ajaxServiceFactory) {
		var log = loggerFactory.getLogger("dashboardDemoService");
		var ajaxService = ajaxServiceFactory.buildAjaxService({
			getPageConfig : {
				url : 'do/cda/dashboardDemo/page',
				method : 'post'
			},
			getPagePanelConfigs : {
				url : 'do/cda/dashboardDemo/page/panels',
				method : 'post'
			},
			getPagePanelConfig : {
				url : 'do/cda/dashboardDemo/page/panel',
				method : 'post'
			},
			getPagePanelData : {
				url : 'do/cda/dashboardDemo/page/panelData',
				method : 'post'
			}
		});
		function getPageConfig(dbdPageCode) {
			var defer = $q.defer();
			ajaxService.getPageConfig({
				'dbdPageCode' : dbdPageCode
			}).then(function(response) {
				defer.resolve(response ? response.data : null);
			}, function(e) {
				defer.reject(e);
			});
			return defer.promise;
		}
		function getPagePanelConfigs(dbdPageId) {
			var defer = $q.defer();
			ajaxService.getPagePanelConfigs({
				'dbdPageId' : dbdPageId
			}).then(function(response) {
				defer.resolve(response ? response.data : null);
			}, function(e) {
				defer.reject(e);
			});
			return defer.promise;
		}
		function getPagePanelConfig(dbdPagePanelId) {
			var defer = $q.defer();
			ajaxService.getPagePanelConfig({
				'dbdPagePanelId' : dbdPagePanelId
			}).then(function(response) {
				defer.resolve(response ? response.data : null);
			}, function(e) {
				defer.reject(e);
			});
			return defer.promise;
		}
		function getPagePanelData(dbdPagePanelId, params) {
			var defer = $q.defer();
			ajaxService.getPagePanelData({
				'dbdPagePanelId' : dbdPagePanelId,
				'params' : params
			}).then(function(response) {
				defer.resolve(response ? response.data : null);
			}, function(e) {
				defer.reject(e);
			});
			return defer.promise;
		}
		return {
			getPageConfig : getPageConfig,
			getPagePanelConfigs : getPagePanelConfigs,
			getPagePanelConfig : getPagePanelConfig,
			getPagePanelData : getPagePanelData
		};
	}
})(angular);